home *** CD-ROM | disk | FTP | other *** search
/ Chip 2007 January, February, March & April / Chip-Cover-CD-2007-02.iso / Pakiet bezpieczenstwa / mini Pentoo LiveCD 2006.1 / mpentoo-2006.1.iso / livecd.squashfs / usr / lib / python2.4 / test / test_structseq.pyc (.txt) < prev    next >
Python Compiled Bytecode  |  2005-10-18  |  4KB  |  125 lines

  1. # Source Generated with Decompyle++
  2. # File: in.pyc (Python 2.4)
  3.  
  4. import unittest
  5. from test import test_support
  6. import time
  7.  
  8. class StructSeqTest(unittest.TestCase):
  9.     
  10.     def test_tuple(self):
  11.         t = time.gmtime()
  12.         astuple = tuple(t)
  13.         self.assertEqual(len(t), len(astuple))
  14.         self.assertEqual(t, astuple)
  15.         for i in xrange(-len(t), len(t)):
  16.             self.assertEqual(t[i:], astuple[i:])
  17.             for j in xrange(-len(t), len(t)):
  18.                 self.assertEqual(t[i:j], astuple[i:j])
  19.             
  20.         
  21.         for j in xrange(-len(t), len(t)):
  22.             self.assertEqual(t[:j], astuple[:j])
  23.         
  24.         self.assertRaises(IndexError, t.__getitem__, -len(t) - 1)
  25.         self.assertRaises(IndexError, t.__getitem__, len(t))
  26.         for i in xrange(-len(t), len(t) - 1):
  27.             self.assertEqual(t[i], astuple[i])
  28.         
  29.  
  30.     
  31.     def test_repr(self):
  32.         t = time.gmtime()
  33.         repr(t)
  34.  
  35.     
  36.     def test_concat(self):
  37.         t1 = time.gmtime()
  38.         t2 = t1 + tuple(t1)
  39.         for i in xrange(len(t1)):
  40.             self.assertEqual(t2[i], t2[i + len(t1)])
  41.         
  42.  
  43.     
  44.     def test_repeat(self):
  45.         t1 = time.gmtime()
  46.         t2 = 3 * t1
  47.         for i in xrange(len(t1)):
  48.             self.assertEqual(t2[i], t2[i + len(t1)])
  49.             self.assertEqual(t2[i], t2[i + 2 * len(t1)])
  50.         
  51.  
  52.     
  53.     def test_contains(self):
  54.         t1 = time.gmtime()
  55.         for item in t1:
  56.             self.assert_(item in t1)
  57.         
  58.         self.assert_(-42 not in t1)
  59.  
  60.     
  61.     def test_hash(self):
  62.         t1 = time.gmtime()
  63.         self.assertEqual(hash(t1), hash(tuple(t1)))
  64.  
  65.     
  66.     def test_cmp(self):
  67.         t1 = time.gmtime()
  68.         t2 = type(t1)(t1)
  69.         self.assertEqual(t1, t2)
  70.         self.assert_(not (t1 < t2))
  71.         self.assert_(t1 <= t2)
  72.         self.assert_(not (t1 > t2))
  73.         self.assert_(t1 >= t2)
  74.         self.assert_(not (t1 != t2))
  75.  
  76.     
  77.     def test_fields(self):
  78.         t = time.gmtime()
  79.         self.assertEqual(len(t), t.n_fields)
  80.         self.assertEqual(t.n_fields, t.n_sequence_fields + t.n_unnamed_fields)
  81.  
  82.     
  83.     def test_constructor(self):
  84.         t = time.struct_time
  85.         self.assertRaises(TypeError, t)
  86.         self.assertRaises(TypeError, t, None)
  87.         self.assertRaises(TypeError, t, '123')
  88.         self.assertRaises(TypeError, t, '123', dict = { })
  89.         self.assertRaises(TypeError, t, '123456789', dict = None)
  90.         s = '123456789'
  91.         self.assertEqual(''.join(t(s)), s)
  92.  
  93.     
  94.     def test_eviltuple(self):
  95.         
  96.         class Exc(Exception):
  97.             pass
  98.  
  99.         
  100.         class C:
  101.             
  102.             def __getitem__(self, i):
  103.                 raise Exc
  104.  
  105.             
  106.             def __len__(self):
  107.                 return 9
  108.  
  109.  
  110.         self.assertRaises(Exc, time.struct_time, C())
  111.  
  112.     
  113.     def test_reduce(self):
  114.         t = time.gmtime()
  115.         x = t.__reduce__()
  116.  
  117.  
  118.  
  119. def test_main():
  120.     test_support.run_unittest(StructSeqTest)
  121.  
  122. if __name__ == '__main__':
  123.     test_main()
  124.  
  125.